package code20_jdbc.改写学生管理.view;

import java.util.List;
import java.util.Scanner;

import code20_jdbc.改写学生管理.dao.ClazzDao;
import code20_jdbc.改写学生管理.entity.Clazz;

public class ClazzView {
	Scanner input = new Scanner(System.in);
	ClazzDao clazzDao = new ClazzDao();

	public void showMenu(){
		System.out.println("-----------------------------");
		System.out.println("1. 查询所有班级");
		System.out.println("2. 根据班级号查询班级	");
		System.out.println("3. 添加班级");
		System.out.print("请选择：");
		int choice = input.nextInt();
		switch(choice){
			case 1:
				findAll();
				break;
			case 2:
				findById();
				break;
			case 3:
				add();
				break;
		}
	}


	private void findAll() {
		List<Clazz> list = clazzDao.selectAll();
		System.out.println(list);
	}


	private void findById() {
	}


	private void add() {
		Clazz clazz = new Clazz();
		System.out.print("请输入班级名称：");
		clazz.setCname(input.next());
		System.out.print("请输入所在教室：");
		clazz.setRoom(input.next());
		
		clazzDao.insert(clazz);
		System.out.println("添加成功");
	}
	
	
	
	
}
